﻿<!DOCTYPE html>

<html class="x-admin-sm">
<head>
    <meta name="viewport" content="width=device-width" />
    <meta charset="UTF-8">
    <title>生产计划</title>
    <meta name="renderer" content=padding>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link href="~/js/layui/css/layui.css" rel="stylesheet" />
    <link href="~/X-admin/css/font.css" rel="stylesheet" />
    <script src="~/X-admin/lib/layui/layui.js"></script>
    <link href="~/X-admin/css/xadmin.css" rel="stylesheet" />
    <script src="~/X-admin/js/jquery.min.js"></script>
    <script src="~/X-admin/js/xadmin.js"></script>

</head>
<body>
    <div class="layui-fluid" style="width:100%;">
        <div id="bDiv">
        </div>
        <div style="float:left;width:100%;">
            <div class="layui-card">

                <div class="layui-card-body" style="margin-top:5px">
                    <form class="layui-form layui-col-space5" name="qForm" id="qForm">
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" name="byCode" placeholder="版号" autocomplete="off" class="layui-input" id="byCode">
                        </div>
                       @*  <div class="layui-inline layui-show-xs-block">
                            <input type="text" name="byBarCode" placeholder="版辊编码" autocomplete="off" class="layui-input" id="byBarCode">
                        </div> *@
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" name="supName" placeholder="供方名称" autocomplete="off" class="layui-input" id="supName" >
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" name="byName" placeholder="版辊名称" autocomplete="off" class="layui-input" id="byName" >
                        </div>

                    </form>
                </div>
            

                <div class="layui-card-body layui-table-body layui-table-main" id="layui-table-main">
                    <table class="layui-hide" id="list" lay-filter="list"></table>
                </div>
            </div>


        </div>
    </div>
</body>
</html>
<script src="~/js/framework/sysframework.js"></script>
<script src="~/js/framework/commonjs.js"></script>
<script src="~/js/sysweb/planjs.js"></script>
<script type="text/html" id="zyTools">
    <a title="查看" href="javascript:;" lay-event="view" id="frmView"><i class="layui-icon">&#xe615;</i></a>
    <a title="删除" href="javascript:;" lay-event="del" id="frmDel"><i class="layui-icon">&#xe640;</i></a>
</script>
<script>
    var webCode = "";

    var selectList = new Array();

    $(function () {
        webCode = getUrlVariable("menuCode");
        BannerData(webCode, "bDiv");
        DictionaryDropDown("pst", "status", "", true);
        loadData();
    })
    function openQueryWin() {
        gjQuery = true;
        InfoOpenPage("../System/QueryWeb?webCode=" + webCode, "高级检索", "85%", "80%");
    }
    function SetPro() {
        if (cData == "") {
            layer.msg("请先选择版辊数据"); return;
        }
        var url = dUrl + JSON.stringify(FormToJson("qForm"));
        NewOpenPage("../Basic/SetBanGunPro?barCodes=" + cData, "版辊存货配置", "85%", "80%", "list", currPage, url);
    }




    var currPage = 1;//首先默认值为1，防止出错
    var cData = "";
    var dUrl = '../Basic/GetDataList?dataType=bgl&condition=' //数据接口
    /**
     * 加载数据
     * **/
    function loadData() {
     

        if (!gjQuery) {
            qStr = FormToJson("qForm");
        }

        gjQuery = false;
        layui.use('table', function () {
            var condition = JSON.stringify(qStr);
            var table = layui.table;
            table.render({
                elem: '#list'
                , height: 'full-200'   //固定高度-即固定表头固定第一行首行
                , cols: [[ //标题栏
                    { type: 'checkbox' }
                    , { field: 'byBarCode', title: '版辊编码', width: 130 }    //U8存货档案版辊类   的 cFree（版号）
                    , { field: 'byName', title: '版辊名称', width: 230 }    //U8存货档案版辊类  的存货名称
                    , { field: 'byCode', title: '版号', width: 120 }  //同版辊编码
                    , { field: 'banchang', title: '版长', width: 90 }
                    , { field: 'banzhou', title: '版周', width: 100 }
                    , { field: 'money', title: '价格', width: 100 }
                    , { field: 'supName', title: '供方名称', width: 190 }
                    , { field: 'houseName', title: '入库仓库', width: 120 }
                    , { field: 'statusName', title: '在库状态', width: 120 }
                    , { field: 'PPlan', title: '关联计划单', width: 120 }
                    , { field: 'relationErpCode', title: 'ERP单号', width: 120 }
                    , { field: 'right', align: 'center', title: '', toolbar: '#zyTools', width: 90, fixed: 'right' }
                ]], done: function (res, curr, count) {
                    // $("[data-field='id']").css('display', 'none');//隐藏列
                    currPage = curr;
                    TablePowerHide();
                    var date = getDate(0);
                    $.each(res['data'], function (i, j) {
                        if (j['proCode'] == "" || j['money'] == "") {
                            TableRowColor('layui-table-main', i, '#FFFFAA');
                        }
                    });
                }
                , url: dUrl+condition //数据接口
                , skin: 'row' //表格风格
                , even: true
                , page: true //是否显示分页
                , limits: [20, 25, 30]
                , limit: 20 //每页默认显示的数量
                , id: "list"
            });

            //监听工具条
            table.on('tool(list)', function (obj) {
                var data = obj.data;
                if (obj.event == 'view') {
                    var webUrl = "../Basic/BanGunDetails?byCode=" + data.byBarCode;
                    var title = data.byBarCode + "-详情";
                    NewOpenPage(webUrl, title, "95%", "90%", "list", currPage, dUrl);
                } else if (obj.event == 'del') {
                    layer.confirm('确认要删除该数据？', function (index) {
                        var info = DelData(data.byCode);
                        if (info.result) {
                            layer.msg("删除成功");
                            obj.del();
                        } else {
                            layer.msg(info.message);
                        }
                        layer.close(index);
                    });
                }
                
            

            });

            /**复选框**/
            table.on('checkbox(list)', function (obj) {
                var select = "";
                var checkStatus = table.checkStatus('list');
                for (var i = 0; i < checkStatus.data.length; i++) {
                
                    select+=checkStatus.data[i].byBarCode+",";
                }
                cData=select.slice(0, -1);
            });
          
        });

    }


    //手动同步版辊信息   (版周 版长 名称 客户)
    function SyncBg() { 
        var index = layer.load(1, { shade: [0.7, '#393D49'] }, { shadeClose: true }); //0代表加载的风格，支持0-2
        $.ajax({
            url: "../System/SyncData",
            data: { syncCode: "bg" },
            dataType: "json",
            type: "POST",
            success: function (rsl) {
                if (rsl.result) {
                    layer.msg("同步执行成功");
                } else {
                    layer.msg(data.message);
                }
                layer.close(index);
            }
        });
    }


    /**
    版辊信息删除
    **/
    function DelData(byCode) {
        var info = undefined;
        $.ajax({
            url: "../Basic/DelBanGun",
            data: { byCode: byCode },
            dataType: "json",
            type: "POST",
            async: false,
            success: function (data) {
                info = data;
            }
        });
        return info;
    }



</script>
